package com.example.androidaudiovideodemo

import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView

/**
 *
 * author: renbing
 *
 * date: 2021/12/13
 *
 * des:
 */
class CustomImageView @JvmOverloads constructor(context: Context,attrs: AttributeSet? = null,defStyle: Int = 0): AppCompatImageView(context, attrs,defStyle){
    private var mPaint: Paint? = null
    private var mBitmap: Bitmap? = null

    init {
        mPaint = Paint(Paint.ANTI_ALIAS_FLAG)
        mBitmap = BitmapFactory.decodeResource(context.resources,R.mipmap.test_iv)
    }

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)

        mBitmap?.let {
            canvas?.drawBitmap(it,0f,0f,mPaint)
        }

    }
}